package com.wushi.lenovo.asia5b.app_widget.mingan;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.wushi.lenovo.asia5b.R;

/**
 * Created by zhangyuncai on 2019/11/2.
 * 里面包含敏感词的ImageView容器
 */
public class MinganImageView extends FrameLayout {
    private ImageView iv_mingan_img;
    private LinearLayout ll_mingan_text;
    private View rootView;

    public MinganImageView(@NonNull Context context) {
        super(context);
        init();
    }

    public MinganImageView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public MinganImageView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        rootView = View.inflate(getContext(), R.layout.layout_mingan, this);
        ll_mingan_text = rootView.findViewById(R.id.ll_mingan_text);
        iv_mingan_img = rootView.findViewById(R.id.iv_mingan_img);
    }

    public ImageView getImageView() {
        return iv_mingan_img;
    }

    /**
     * 是否显示敏感词语
     * @param isMingan true/显示
     */
    public void setMinganTextVisibility(boolean isMingan) {
        ll_mingan_text.setVisibility(isMingan ? View.VISIBLE : View.GONE);
    }
}
